#ifndef MYSQL_CONNECTION_POOL_H
#define MYSQL_CONNECTION_POOL_H

#include <mysql/mysql.h>
#include <string>
#include <vector>
#include <mutex>
#include <condition_variable>

class MySQLConnectionPool {
private:
    std::vector<MYSQL*> pool;
    std::mutex mtx;
    std::condition_variable cv;
    const int max_connections;

public:
    MySQLConnectionPool(const std::string& host, const std::string& user,
                        const std::string& password, const std::string& db,
                        int max_conn);
    ~MySQLConnectionPool();

    MYSQL* getConnection();
    void releaseConnection(MYSQL* conn);

    // 禁止拷贝构造和赋值操作
    MySQLConnectionPool(const MySQLConnectionPool&) = delete;
    MySQLConnectionPool& operator=(const MySQLConnectionPool&) = delete;
};

#endif // MYSQL_CONNECTION_POOL_H